package com.aisino.api.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Component
public class RedisUtil {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    public boolean isProcessed(String transactionId) {
        return stringRedisTemplate.hasKey(transactionId);
    }

    public void markAsProcessed(String transactionId) {
        stringRedisTemplate.opsForValue().set(transactionId, "1", 300, TimeUnit.MINUTES);
    }
}
